import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'flex',
    component: () => import( '@/components/flex.vue')
  },
  {
    path: '/about',
    name: 'about',
    redirect:'/first',
    component: () => import( '@/components/About.vue'),
    children:[
      {path:'/first',component:() => import( '@/components/right/first.vue')},
      {path:'/second/:id',component:() => import( '@/components/right/second.vue')},
      {path:'/third',component:() => import( '@/components/right/third.vue')},
      {path:'/forth',component:() => import( '@/components/right/forth.vue')},
    ]
  },
  {
    path: '/tab',
    name: 'tab',
    component: () => import( '@/components/tab.vue'),
    children:[
      {path:'/tab/third',component:() => import( '@/components/right/third.vue')},
      {path:'/tab/forth/:id',name:'/tab/forth',component:() => import( '@/components/right/forth.vue')},
    ]
  },
  {
    path: '/tab2',
    name: 'tab2',
    component: () => import( '@/components/tab2.vue'),
    
  }
]

const router = new VueRouter({
  routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
